<?php require VIEW_ROOT.'/common/header.php'?>

<form action="?m=finance&a=pay_add" method="post">
<table>
	<tr>
		<th colspan="2">添加支出</th>
	</tr>
	<tr>
		<td width="100">说明</td>
		<td class="frm"><input type="text" name="pay_name" value="" /></td>
	</tr>
	<tr>
		<td>金额</td>
		<td class="frm"><input type="text" name="amount" value="1" style="width:50px;" /></td>
	</tr>
	<tr>
		<td>时间</td>
		<td class="frm">
			<input type="text" name="create_time" id="create_time" value="<?php echo date('Y-n-j')?>" style="width:95px;" />
			<input type="button" onclick="create_time_add(1);" value="+" />
			<input type="button" onclick="create_time_add(-1);" value="-" />
			<script>
			function create_time_add(days) {
				var dom = document.getElementById('create_time');

				var dateStr = dom.value;
				var dateArr = dateStr.split('-');
				if (dateArr.length !== 3)
				{
					alert('日期格式错误！');
					return false;
				}
				var date = new Date(dateArr[0], dateArr[1] - 1, dateArr[2]);
				if (date == 'Invalid Date') {
					alert('日期格式错误！');
					return false;
				}
				var newDate = new Date(date.getTime() + 86400000 * days);
				var newDateString = newDate.getFullYear() + '-' + (newDate.getMonth() + 1) + '-' + newDate.getDate();

				dom.value = newDateString;
			}
			</script>
		</td>
	</tr>
	<tr>
		<td></td>
		<td class="frm"><input type="submit" value="提交" /></td>
	</tr>
</table>
</form>

<?php require VIEW_ROOT.'/common/footer.php'?>
